package com.hbnu.thread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author kittychen
 * @since 2025-10-24 17:02
 */
public class ThreadTest {
    public static void main(String[] args) {
        ThreadDemo01 threadDemo01 = new ThreadDemo01();  // 创建线程对象
        threadDemo01.start();  // 启动线程

        ThreadDemo02 threadDemo02 = new ThreadDemo02();  // 创建线程对象
        new Thread(threadDemo02).start();   // 启动线程

        ThreadDemo03 threadDemo03 = new ThreadDemo03();   // 创建线程对象
        FutureTask<String> stringFutureTask = new FutureTask<String>(threadDemo03);
        new Thread(stringFutureTask).start();   // 启动线程

        try {
            // 获取Call方法的返回值
            String result = stringFutureTask.get();
            System.out.println(result);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        } catch (ExecutionException e) {
            throw new RuntimeException(e);
        }


        for (int i = 101; i < 201; i++) {
            System.out.println("主线程：" + i);
        }
    }
}
